package com.duyj.server.stock.controller;

import com.duyj.client.stock.feign.StockFeignService;
import com.duyj.client.stock.model.Stock;
import com.duyj.server.stock.service.StockService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StockController implements StockFeignService {

    Logger logger = LoggerFactory.getLogger(StockController.class);

    @Autowired
    private StockService stockService;

    @Override
    public String updateStock(String code) {
        logger.info("stock code: " + code);
        return stockService.updateStock(code);
    }

    @Override
    public void putStock(Stock stock) {
        logger.info("stock:" + stock);
        stockService.putStock(stock.getName(), stock.getCode());
    }

    @Override
    public String getStockName(String code) {
        return stockService.getStockName(code);
    }

}
